import React from 'react';
import { ModalProps } from 'antd';
import type { DraggableProps } from 'react-draggable';
import Drag from './components/Drag';
import Common from './components/Common';
import './index.less';
import '../../src/styles/global.less';

interface ModalPropsWithMore extends ModalProps {
  /**
   * 超出后是否在整屏滚动：默认false,在弹窗body中滚动
   */
  screenScroll?: boolean;
}
interface DragProps {
  /**
   * 拖拽属性：react-draggable中支持的所有属性
   */
  dragProps?: DraggableProps | boolean;
}

interface Props extends DragProps, ModalPropsWithMore {}

const QFModal: React.FC<Props> = ({
  children,
  screenScroll = false,
  ...props
}) => {
  const { dragProps, ...modalProps } = props;


  return dragProps ? (
    <Drag
      children={children}
      dragProps={dragProps===true?{}:dragProps}
      screenScroll={screenScroll}
      {...modalProps}
    />
  ) : (
    <Common children={children} screenScroll={screenScroll} {...modalProps} />
  );
};

export default QFModal;
